def triangles():
    N = [1]
    while True:
        yield N # 返回N这个List
        N.append(0) # 追加一个0
        N = [N[i-1]+N[i] for i in range(len(N))] #当i = 0 时，N[0-1] + N[0] = N[0] 即N[-1] = 0是补上去的，不影响结果

        # 用错位相加的方法
        
        # 0 1 0
        # 0 1 1 0
        # 0 1 2 1 0
        #   1 3 3 1

n = 0
for t in triangles():
    print(t)
    n += 1
    if n == 10:
        break